<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>注释</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.instruction-separation.html">指令分隔符</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.types.html">类型</a></div>
 <div class="up"><a href="language.basic-syntax.html">基本语法</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="language.basic-syntax.comments" class="sect1">
  <h2 class="title">注释</h2>
  <p class="para">
   PHP 支持 C，C++ 和 Unix Shell 风格（Perl 风格）的注释。例如:
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;a&nbsp;test"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;a&nbsp;one-line&nbsp;c++&nbsp;style&nbsp;comment<br />&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;This&nbsp;is&nbsp;a&nbsp;multi&nbsp;line&nbsp;comment<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yet&nbsp;another&nbsp;line&nbsp;of&nbsp;comment&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;yet&nbsp;another&nbsp;test"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'One&nbsp;Final&nbsp;Test'</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">#&nbsp;This&nbsp;is&nbsp;a&nbsp;one-line&nbsp;shell-style&nbsp;comment<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="simpara">
   单行注释仅仅注释到行末或者当前的 PHP 代码块，视乎哪个首先出现。这意味着在
   <em>// ... ?&gt;</em> 或者 <em># ...  ?&gt;</em>
   之后的 HTML 代码将被显示出来：?&gt;
   跳出了 PHP 模式并返回了 HTML 模式，<em>//</em> 或 <em>#</em>
   并不能影响到这一点。如果启用了
   <a href="ini.core.html#ini.asp-tags" class="link">asp_tags</a> 配置选项，其行为和
   <em>// %&gt;</em> 或 <em># %&gt;</em>
   相同。不过，<em>&lt;/script&gt;</em>
   标记在单行注释中不会跳出 PHP 模式。
  </p>
  <p class="para">
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
&lt;h1&gt;This&nbsp;is&nbsp;an&nbsp;<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #FF8000">#&nbsp;echo&nbsp;'simple';</span><span style="color: #0000BB">?&gt;</span>&nbsp;example&lt;/h1&gt;<br />&lt;p&gt;The&nbsp;header&nbsp;above&nbsp;will&nbsp;say&nbsp;'This&nbsp;is&nbsp;an&nbsp;&nbsp;example'.&lt;/p&gt;</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="simpara">
   C 风格的注释在碰到第一个 <em>*/</em>
   时结束。要确保不要嵌套 C 风格的注释。试图注释掉一大块代码时很容易出现该错误。
  </p>
  <p class="para">
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;</span><span style="color: #FF8000">/*<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;"This&nbsp;is&nbsp;a&nbsp;test";&nbsp;/*&nbsp;This&nbsp;comment&nbsp;will&nbsp;cause&nbsp;a&nbsp;problem&nbsp;*/<br />&nbsp;</span><span style="color: #007700">*/<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.instruction-separation.html">指令分隔符</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.types.html">类型</a></div>
 <div class="up"><a href="language.basic-syntax.html">基本语法</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
